import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode:"history",
  routes: [
    {
      path:"/",
      component: resolve => require(['../views/Login.vue'], resolve),
    },
    {
      path: '/home',
      component: resolve => require(['../views/sys/Home.vue'], resolve),
      children: [
        {
          path: '/home',
          component: resolve => require(['../views/sys/homePage.vue'], resolve),
          meta: {
            title: '系统首页',
          }
        },
        {
          path: '/role',
          component: resolve => require(['../views/sys/Role.vue'], resolve),
          meta: {
            title: '角色管理',
          }
        },
        {
          path: '/addrole',
          component: resolve => require(['../views/sys/AddRole.vue'], resolve),
          meta: {
            title: '新增角色',
          }
        },
        {
          path: '/updaterole',
          component: resolve => require(['../views/sys/UpdateRole.vue'], resolve),
          meta: {
            title: '修改角色',
          }
        },
        {
          path: '/right',
          component: resolve => require(['../views/sys/Right.vue'], resolve),
          meta: {
            title: '权限管理',
          }
        },
         {
          path: '/404',
          component: resolve => require(['../components/common/404.vue'], resolve),
          meta: {
            title: '404'
          }
        },
        {
          path: "/user",
          component:resolve => require(['../views/sysuser/User.vue'],resolve),
          meta: {
            title: '用户管理'
          }
        },
        {
          path:'/teacher',
          component:resolve => require(['../views/teacher/TeacherList.vue'],resolve),
          meta: {
            title: '教师管理'
          }
        },
        {
          path: '/updateTeacher',
          component:resolve => require(['../views/teacher/UpdateTeacher.vue'],resolve),
          meta: {
            title: '修改教师'
          }
        },
        {
          path: '/organization',
          component:resolve => require(['../views/organization/OrgList'],resolve),
          meta: {
            title: '教学机构管理'
          }
        },
        {
          path:'/updateOrg',
          component:resolve => require(['../views/organization/updateOrg'],resolve),
          meta: {
            title: '机构信息修改'
          }
        },
        {
          path:'/department',
          component:resolve => require(['../views/department/dept.vue'],resolve),
          meta: {
            title: '销售团队'
          }
        },
        {
          path: '/saler',
          component:resolve => require(['../views/department/saler.vue'],resolve),
          meta: {
            title: '销售人员'
          }
        }
      ]
    },
    {
      path: '/study',
      component: resolve => require(['../views/study/home.vue'], resolve),
      children: [
        {
          path: '/study',
          component: resolve => require(['../views/sys/homePage.vue'], resolve),
          meta: {
            title: '系统首页',
            index: 1
          }
        }, {
          path: '/demo',
          component: resolve => require(['../views/study/demo.vue'], resolve),
          meta: {
            title: 'demo',
            index: 2
          }
        }, {
          path: '/demo1',
          component: resolve => require(['../views/study/demo1.vue'], resolve),
          meta: {
            title: 'demo1'
          }
        }, {
          path: '/404',
          component: resolve => require(['../components/common/404.vue'], resolve),
          meta: {
            title: '404'
          }
        },
        {
          path: '/addOrg',
          component:resolve => require(['../views/organization/addOrg'],resolve),
          meta: {
            title: '添加机构'
          }
        }
      ]
    },
    {
      path: '*',
      redirect: '/404'
    }
  ]
})
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
